/*
*Copyright 2021-2023 NERCIS
*
*Licensed under the Apache License, Version 2.0 (the "License");
*you may not use this file except in compliance with the License.
*You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*Unless required by applicable law or agreed to in writing, software
*distributed under the License is distributed on an "AS IS" BASIS,
*WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*See the License for the specific language governing permissions and
*limitations under the License.
*/

package cn.ac.nercis.pes.common.constant.knowledge;

import org.apache.commons.lang3.StringUtils;

import java.util.Arrays;
import java.util.List;

/**
 * 测评方式
 * @author zpy
 * @version 1.0.0
 */
public enum EvaluationMethod {
    /**测评方式**/
    DEFAULT(0,"",""),
    INTERVIEW(1,"访    谈","访谈"),
    DOCUMENT_REVIEW(2,"文档审查","文档审查"),
    FIELD_VIEW(3,"实地查看","实地查看"),
    CONFIGURATION_CHECK(4,"配置检查","配置检查"),
    TOOLS_TESTING(5,"工具测试","工具测试");

    private final int method;
    private final String name;
    private final String value;

    EvaluationMethod(int method, String name,String value) {
        this.method = method;
        this.name = name;
        this.value = value;
    }

    public static EvaluationMethod fromMethod(Integer method){
        EvaluationMethod data = DEFAULT;
        for(EvaluationMethod tt :EvaluationMethod.values()){
            if(tt.method == method){
                data = tt;
                break;
            }
        }
        return data;
    }

    public static EvaluationMethod fromValue(String value){
        EvaluationMethod data = DEFAULT;
        for(EvaluationMethod tt :EvaluationMethod.values()){
            if(StringUtils.equals(tt.getValue(),value)){
                data = tt;
                break;
            }
        }
        return data;
    }

    public static List<EvaluationMethod> getTechnologyEvaluationMethods(){
        return Arrays.asList(INTERVIEW,DOCUMENT_REVIEW,FIELD_VIEW,CONFIGURATION_CHECK,TOOLS_TESTING);
    }

    public static List<EvaluationMethod> getManageEvaluationMethods(){
        return Arrays.asList(INTERVIEW,DOCUMENT_REVIEW);
    }

    public int getMethod(){
        return this.method;
    }

    public String getName(){
        return this.name;
    }

    public String getValue(){
        return this.value;
    }
}